<?php

namespace App\Console;

use App\Jobs\CloseOrder;
use App\Jobs\CreateCarUsedDate;
use App\Jobs\CreateRevenueDate;
use App\Jobs\CreateRevenueData;
use App\Jobs\SqcChaoshi;
use App\Jobs\MonthOrderTip;
use App\Jobs\TestOrder;
use App\Jobs\LeaseTime;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use League\Flysystem\Exception;
use Modules\Car\Jobs\MaintainJob;
use Modules\Car\Jobs\MaintenanceOverTimeJob;
use Modules\Car\Jobs\ServiceOverTimeJob;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        //
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')->hourly();
        $schedule->command('telescope:prune')->daily();
        //定时任务测试
        // $schedule->job(new TestOrder())->everyMinute();
        //定时关闭单
        $schedule->job(new CloseOrder())->everyMinute();
       // $schedule->job(new LeaseTime())->everyFiveMinutes();
        //车辆保险
        $schedule->job(new MaintainJob())->everyMinute();
        //车辆维修
        $schedule->job(new ServiceOverTimeJob())->everyMinute();
        //车辆保养
        $schedule->job(new MaintenanceOverTimeJob())->everyMinute();
        // 每年1月1日执行车系日历生成
        $schedule->job(new CreateCarUsedDate())->weekly();
        // 每年1月1日执行应收月份生成
        $schedule->job(new CreateRevenueDate())->weekly();
        // 每日0点更新营收数据
        // $schedule->job(new CreateRevenueData())->daily();
        $schedule->job(new CreateRevenueData())->dailyAt('02:00');
        // $schedule->job(new CreateRevenueData())->everyMinute();
        // 发送超时提醒
        $schedule->job(new SqcChaoshi())->everyMinute();
        // 发送月租账单对账提醒，每天10点发送提醒
        $schedule->job(new MonthOrderTip())->dailyAt('10:00');
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}
